from django.conf.urls import patterns, include, url
from ajax_select import urls as ajax_select_urls
from django.utils.translation import ugettext_lazy as _

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
from academia import settings

admin.autodiscover()


def generate_urls(app, model):
    singular = model._meta.verbose_name._proxy____args[0].lower().replace(" ", "_")
    plural = model._meta.verbose_name_plural._proxy____args[0].lower().replace(" ", "_")

    return [
        url(_(r'^' + singular + '/$'), '%s.views.%s' % (app, singular), name=singular),
        url(_(r'^' + plural + '/$'), '%s.views.%s' % (app, plural), name=plural),
        url(_(r'^' + singular + '/edit/(?P<' + singular + '>[\w_-]+)/$'), '%s.views.%s_edit' % (app, singular), name='%s_edit' % singular),
        url(_(r'^' + singular + '/delete/(?P<' + singular + '>[\w_-]+)/$'), '%s.views.%s_delete' % (app, singular), name='%s_delete' % singular)
    ]

urlpatterns = patterns('',
    # Uncomment the admin/doc line below to enable admin documentation:
    (r'^admin/lookups/', include(ajax_select_urls)),
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    (r'^media/(.*)$', 'django.views.static.serve',
     {'document_root': settings.MEDIA_ROOT}),
    (r'^i18n/', include('django.conf.urls.i18n')),
    url(r'^admintools/', include('admin_tools.urls')),
    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),

    url(r'', include('core.urls')),
    url(r'', include('gym.urls')),
    url(r'', include('financier.urls')),
)